package com.code.day05;

public class Day05DoubleArray {

    public static void main(String[] args) {

        //获取二维数组长度
        int[][] array1 = new int[][] {{1,2,3},{4,5,6},{7,8,9}};
        System.out.println(array1.length);

        //获取二维数组元素
        String[][] array2 ={{"乔峰","虚竹","段誉"},{"张无忌","灭绝","周芷若"},{"郭靖","黄蓉"}};
        System.out.println(array2[1][1]);
        System.out.println(array2[2][0]);
        System.out.println(array2[0][2]);

        //二维数组中存储元素
        String[][] array3 = new String[3][3];
        array3[0][0] = "乔峰";
        array3[0][1] = "虚竹";
        array3[0][2] = "段誉";
        array3[1][0] = "张无忌";
        array3[1][1] = "灭绝";
        array3[1][2] = "周芷若";
        array3[2][0] = "郭靖";
        array3[2][1] = "黄蓉";
        array3[2][2] = "小龙女";
        System.out.println(array3[1][1]);
        System.out.println(array3[2][0]);
        System.out.println(array3[0][2]);
        System.out.println(array3[1][2]);
        System.out.println(array3[2][2]);
        System.out.println(array3[2][1]);
        System.out.println(array3[0][0]);
        System.out.println(array3[0][1]);
        System.out.println(array3[1][0]);
        System.out.println(array3[1][1]);

        //二维数组的遍历
        int[][] arr = new int[3][3];
        arr[0][0] = 10;
        arr[0][1] = 20;
        arr[0][2] = 30;

        arr[1][0] = 100;
        arr[1][1] = 200;
        arr[1][2] = 300;

        arr[2][0] = 1000;
        arr[2][1] = 2000;
        arr[2][2] = 3000;
        for(int i = 0 ; i<arr.length;i++){
            for (int j =0 ; j<arr[i].length;j++){
                System.out.println(arr[i][j]);
            }
        }
    }

}
